//
//  GroupPSWViewController.m
//  AAIM
//
//  Created by awh on 2019/12/3.
//  Copyright © 2019年 AAIM. All rights reserved.
//

#import "GroupPSWViewController.h"
#import "HWTFCursorView.h"
@interface GroupPSWViewController ()<HWTFCursorViewDelegate>
@property (nonatomic, strong) HWTFCursorView *codeView;
@property(nonatomic,strong)NSString*markText;
@end

@implementation GroupPSWViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.gk_navTitle=@"群口令";
    [self setUI];
    self.view.backgroundColor=[UIColor whiteColor];
}
-(void)setUI
{
    // 导航右按钮
    UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [rightBtn setTitle:@"保存" forState:UIControlStateNormal];
    [rightBtn addTarget:self action:@selector(saveClick:) forControlEvents:UIControlEventTouchUpInside];
    [rightBtn sizeToFit];
    [rightBtn setBackgroundColor:KHEXCOLOR(kMainColor)];
    rightBtn.frame = CGRectMake(0, 0, 40, 25);
    rightBtn.layer.cornerRadius = 2;
    rightBtn.layer.masksToBounds = YES;
    rightBtn.titleLabel.font = kMainFont(12);
    rightBtn.jk_touchAreaInsets = UIEdgeInsetsMake(20, 20, 20, 20);
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
//    self.gk_navigationItem.rightBarButtnonItem = rightItem;
    
    UIImageView * head=[[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-35, NavigationBarHeight+50, 70, 70)];
    head.layer.masksToBounds=YES;
    head.layer.cornerRadius=35;
    [head sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",userHeaderImage,_groupHead]] placeholderImage:kHeadGroupPlaceholderImage];

    [self.view addSubview:head];
    
    UILabel *titlelbl = [UILabel new];
    titlelbl.textColor = [UIColor orangeColor];
    titlelbl.font = [UIFont boldSystemFontOfSize:15];
    titlelbl.text = @"朋友可通过口令进入群聊";
    titlelbl.textAlignment=1;
    titlelbl.textColor=KHEXCOLOR(@"#262B2F");
    titlelbl.frame = CGRectMake(20, head.bottom+20, SCREEN_WIDTH-40, 20);
    [self.view addSubview:titlelbl];
    
    _codeView = [[HWTFCursorView alloc] initWithCount:4 margin:20];
//    _codeView.backgroundColor=[UIColor redColor];
    _codeView.delegate=self;
    if (![NSObject ldy_isEmpty:_groupCode]) {
        [_codeView setGroupCode:_groupCode];
    }
    _codeView.frame = CGRectMake(30,titlelbl.bottom+60 , SCREEN_WIDTH-60, 50);
    [self.view addSubview:self.codeView];
}
-(void)textCode:(NSString *)code
{
    _markText=code;
}
-(void)saveClick:(UIButton*)sender
{
    if ([NSObject ldy_isEmpty:_markText]) {
        [self showTipHudWithText:@"群口令不能为空"];
        return;
    }
    if (self.editorBlock) {
        self.editorBlock(_markText);
    }
    [self.navigationController popViewControllerAnimated:YES];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
